﻿using Microsoft.EntityFrameworkCore;
using My.Domain.Orders;
using My.EntityFrameworkCore.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;

namespace My.EntityFrameworkCore.Orders
{
    public class OrderRepository : EfCoreRepository<DefaultDbContext, Order, Guid>, IOrderRepository
    {
        public OrderRepository(IDbContextProvider<DefaultDbContext> dbContextProvider) : base(dbContextProvider)
        {
        }

        public async Task<Order> GetOrderAsync(Guid id)
        {
            var query = await WithDetailsAsync();
            var entity = await query.Where(x => x.Id == id).FirstOrDefaultAsync();
            var context = await GetDbContextAsync();
            entity.SetReferenceNo("111");

            var entity1 = await query.Where(x => x.Id == id).FirstOrDefaultAsync();
            var a = context.Entry(entity).State;
            return entity;
        }
    }
}
